package inabit.impl.data.types;
/**@author Rafael Rocha*/
public class ContinuousType extends NumericType{
	
	private double min;
	private double max;
	
	public ContinuousType(double min, double max){
		this.min = min;
		this.max = max;
	}
	@Override
	public String getVarValue(String value) {
		return Double.toString(Double.parseDouble(value));
	}

	@Override
	public boolean isAcceptableValue(String value) {
		if(value == null) {return false;}
		try {
			Double d = Double.parseDouble(value);
			boolean acceptable = true;
			acceptable = acceptable && d >= min;
			acceptable = acceptable && d <= max;
			return acceptable;
		}catch(NumberFormatException e) {
			return false;
		}
	}
	@Override
	public String getName() {
		return "continuous";
	}
	@Override
	public String getExtendedName() {
		return "continuous(" + min + ", " + max + ")";
	}

}
